package body;

import java.awt.Graphics;
import java.awt.Rectangle;

/**
 * 一个身体的基类
 * 所有建筑物或者人物都继承于它
 * 有坐标,有占地面积,有画方法
 *
 */
public abstract class Body implements IPainting,IArea{
	
	/** 坐标 */
	private int x;
	
	private int y;

	/** 面积 */
	private int width;
	
	private int height;
	
	public int getX() {
		return x;
	}

	public void setX(int x) {
		if(x < 0){
			x = 0;
		}
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		if(y < 0){
			y = 0;
		}
		this.y = y;
	}
	
	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	@Override
	public abstract void draw(Graphics g);

	@Override
	public Rectangle getRectangle() {

		return new Rectangle(x, y, width, height);
	}
	
}
